<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>js 识别 PC 还是移动端 的浏览器</h1>
			<script type="text/javascript">
				// let userAgentInfo = navigator.userAgent;
				// alert("userAgentInfo:"+userAgentInfo);
		
				// alert("IsPC() :" + IsPC());
				
				var checkMachine=IsPC();
				
				if(checkMachine){
					// alert("IsPC() :" + checkMachine);
					// window.location.href="https://www.bing.com/";
					window.location.href="https://bestming.gitee.io/search_tools/pc.html";
					// window.location.href="http://47.106.70.134:9898/search_tools/pc.html";
 
				}else{
					// alert("IsPC() :" + checkMachine);
					// window.location.href="https://www.baidu.com/";
					window.location.href="https://bestming.gitee.io/search_tools/mobile.html";
					// window.location.href="http://47.106.70.134:9898/search_tools/mobile.html";
				}
				
		
				//判断是否是PC设备，true是，false不是
				function IsPC() {
					var userAgentInfo = navigator.userAgent;
					var Agents = ["Android", "iPhone",
						"SymbianOS", "Windows Phone",
						"iPad", "iPod"
					];
					var flag = true;
					for (var v = 0; v < Agents.length; v++) {
						if (userAgentInfo.indexOf(Agents[v]) > 0) {
							flag = false;
							break;
						}
					}
					return flag;
				}
				
				
			</script>

	</body>
</html>
